package com.lcq.study.lambda;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * @ClassName Test
 * @Description
 * @Author lichuanqi
 * @Date 2022/5/23 15:46
 * @Version 1.0
 **/
public class Test {
    public static void main(String[] args) {
        ArrayList<MyEntity> myEntities = new ArrayList<>();
        MyEntity myEntity = new MyEntity();
        myEntity.setAge(20);
        myEntity.setName("zs");
        myEntities.add(myEntity);

        MyEntity myEntity1 = new MyEntity();
        myEntity1.setAge(21);
        myEntity1.setName("ls");
        myEntities.add(myEntity1);

        MyEntity myEntity2 = new MyEntity();
        myEntity2.setAge(22);
        myEntity2.setName("ww");
        myEntities.add(myEntity2);

        HashMap<String, Integer> map = new HashMap<>();
        map.put("a",1);
        map.put("b",1);
        map.put("c",1);


        myEntities.forEach(item->{
            Integer a = map.get("a");
            if (a != null){
                item.setA(a);
            }
            setValue(MyEntity::getA, "a", item);
        });
    }

    private static void setValue(Function<MyEntity, Integer> consumer, String a, MyEntity item) {

    }

}
